﻿using ViewMaker.Core.Controls;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using ViewMaker.Core;
using System.Collections.Generic;
using System.Windows.Controls;

namespace ViewMaker.Core.Tests
{
    [TestClass()]
    public class CanvasViewControlTest
    {
        [TestMethod()]
        public void 標準的なCanvasのXAML生成()
        {
            var target = new CanvasViewControl { Width = 100, Item = new ViewLayoutItem { Name = "cv001", BindPath = "data" } };
            target.Item.Element = target;
            var txtItem = new ViewLayoutItem { Name = "txt001", Caption = "テキスト", BindPath = "textPath" };
            txtItem.Element = new TextBoxViewControl 
                            { 
                                CanvasTop = 100, 
                                CanvasLeft=100 
                            };
            target.Item.AddChild(txtItem);
            var xaml = target.CreateXaml(TestHelper.CreateTestParent())[0];
            var actual = TestHelper.GetFrameworkElement<Canvas>(xaml);
            Assert.AreEqual("cv001", actual.Name);
            Assert.AreEqual("data", actual.GetBindingExpression(Canvas.DataContextProperty).ParentBinding.Path.Path);

            Assert.AreEqual(100, Canvas.GetLeft(actual.Children[0]));
            Assert.AreEqual(100, Canvas.GetTop(actual.Children[0]));
            Assert.AreEqual("txt001", ((TextBox)((Panel)actual.Children[0]).Children[1]).Name);
        }

        [TestMethod()]
        public void CanvasViewControlの編集画面が表示可能()
        {
            var target = new CanvasViewControl { Width = 100, Item = new ViewLayoutItem { Name = "cv001", BindPath = "data" } };
            var baml = ViewUtil.BuildContent(target);
            Assert.IsNotNull(baml);
        }


    }
}
